import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
import _applyDecoratedDescriptor from "@babel/runtime/helpers/esm/applyDecoratedDescriptor";

var _dec, _dec2, _class;

import { PureComponent } from 'react';
import { Bind } from 'lodash-decorators';
/**
 * 查询表单
 * @extends {PureComponent} - React.PureComponent
 * @reactProps {Function} onSearch - 表单查询
 * @reactProps {Object} form - 表单对象
 * @return React.element
 */

var FilterForm = (_dec = Bind(), _dec2 = Bind(), (_class = /*#__PURE__*/function (_PureComponent) {
  _inherits(FilterForm, _PureComponent);

  var _super = _createSuper(FilterForm);

  function FilterForm(props) {
    var _this;

    _classCallCheck(this, FilterForm);

    _this = _super.call(this, props);
    props.onRef(_assertThisInitialized(_this));
    return _this;
  }
  /**
   * 查询
   */


  _createClass(FilterForm, [{
    key: "handleSearch",
    value: function handleSearch() {
      var _this$props = this.props,
          onSearch = _this$props.onSearch,
          form = _this$props.form;

      if (onSearch) {
        form.validateFields(function (err) {
          if (!err) {
            onSearch();
          }
        });
      }
    }
    /**
     * 重置
     */

  }, {
    key: "handleFormReset",
    value: function handleFormReset() {
      this.props.form.resetFields();
    }
    /**
     * render
     * @returns React.element
     */

  }, {
    key: "render",
    value: function render() {
      var form = this.props.form;
      return this.props.children(form);
    }
  }]);

  return FilterForm;
}(PureComponent), (_applyDecoratedDescriptor(_class.prototype, "handleSearch", [_dec], Object.getOwnPropertyDescriptor(_class.prototype, "handleSearch"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "handleFormReset", [_dec2], Object.getOwnPropertyDescriptor(_class.prototype, "handleFormReset"), _class.prototype)), _class));
export { FilterForm as default };